package fun.lifepoem.files.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Yiwyn
 * @create 2022/7/12 23:07
 */
@Configuration
public class FileWebConfig implements WebMvcConfigurer {


    @Value("${file-warehouse.prefix}")
    private String prefix;

    @Value("${file-warehouse.resourceLocation}")
    private String location;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(prefix + "**").addResourceLocations("file:" + location);
    }
}
